<style>
.a {
    poorfish: expression(this.onclick=function kill(){return false})
}

tr, th, td {
    text-align: center;
}
</style>

<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch"
          action="${request.getContextPath()}/MakeReportOneStep/makeReportOneStep" method="post">
        <div class="bjui-searchBar">
            <g:hiddenField name="SYS_QUERY_NAME" value="makeReportOneStep"/>
            <g:hiddenField name="EXPORT_CONTENT_NAME" value="Excel"/>
            <label>时间段：</label>&nbsp;
            <input type="text" name="startTime" data-pattern="yyyy-MM-dd" size="12" value="${startTime}"
                   data-toggle="datepicker"
                   placeholder="FROM">
            <input type="text" name="endTime" data-pattern="yyyy-MM-dd" size="12" value="${endTime}"
                   data-toggle="datepicker"
                   placeholder="TO">&nbsp;&nbsp;
            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
            <button type="button" class="btn-blue"
                    onclick="javascript:bjuiExportExl('#pagerForm', '${request.getContextPath()}/MakeReportOneStep/exportExcel')"
                    data-icon="file-excel-o" title="导出Excel">导出</button>
        </div>
    </form>
</div>

<div class="bjui-pageContent tableContent">
    <g:if test="${makeReportOneStep.size() > 0}">
        <div>
            <table data-toggle="tablefixed" data-width="100%" data-nowrap="true">
                <thead>
                <tr id="t1">
                    <th width="50" rowspan="2">NO.</th>
                    %{--<g:each in="${tableHeadList}" status="j" var="headInstance">--}%
                    %{--<g:if test="${headInstance != 'RN' && headInstance != 'CREATE_TIME'}">--}%
                    %{--<th><g:message code="${headInstance}" default="${headInstance}"/></th>--}%
                    %{--</g:if>--}%
                    %{--</g:each>--}%
                    <th rowspan="2" colspan="1">纳期要求</th>
                    <th colspan="3">已完成发货</th>
                    <th colspan="3">未完成发货</th>
                    <th rowspan="2">纳期达成率</th>
                </tr>
                <tr>
                    <th>提前完成套数</th>
                    <th>按期完成套数</th>
                    <th>延迟完成套数</th>
                    <th>纳期延迟未完成</th>
                    <th>纳期内未完成</th>
                    <th>订单已关闭</th>
                </tr>
                </thead>
                <tbody>
                <g:each in="${makeReportOneStep}" status="i" var="dataInstance">
                    <tr>
                        <td>${i + 1}</td>
                        <g:each in="${tableHeadList}" status="j" var="headInstance">
                        %{-- 纳期 --}%
                            <g:if test="${headInstance != 'RN' && headInstance != 'TQWC' && headInstance != 'AQWC' && headInstance != 'WWCN' && headInstance != 'WWCW' && headInstance != 'YC' && headInstance != 'DDYWC' && headInstance != 'DCL'}">
                                <td>${dataInstance["${headInstance}"]}</td>
                            </g:if>
                        %{-- 提前完成套数 --}%
                            <g:if test="${headInstance == 'TQWC'}">
                                <td name="TQWC${i}">
                                    <g:if test="${i != makeReportOneStep.size() - 1}">
                                        <a href="${request.getContextPath()}/MakeReport/makeReport?naqi=<%=dataInstance.NAQI%>&yanchi=提前&startTime=${startTime}&endTime=${endTime}"
                                           data-toggle="navtab" data-id="dialog-normal"
                                           data-options="{id:'oneReportStep', title:'制造报表'}">${dataInstance["${headInstance}"]}</a>
                                    </g:if>
                                    <g:else>
                                        ${dataInstance["${headInstance}"]}
                                    </g:else>
                                </td>
                            </g:if>
                        %{-- 按期完成 --}%
                            <g:if test="${headInstance == 'AQWC'}">
                                <td name="AQWC${i}">
                                    <g:if test="${i != makeReportOneStep.size() - 1}">
                                        <a href="${request.getContextPath()}/MakeReport/makeReport?naqi=<%=dataInstance.NAQI%>&yanchi=正常&startTime=${startTime}&endTime=${endTime}"
                                           data-toggle="navtab" data-id="dialog-normal"
                                           data-options="{id:'oneReportStep', title:'制造报表'}">${dataInstance["${headInstance}"]}</a>
                                    </g:if>
                                    <g:else>
                                        ${dataInstance["${headInstance}"]}
                                    </g:else>
                                </td>
                            </g:if>
                        %{-- 延迟 --}%
                            <g:if test="${headInstance == 'YC'}">
                                <td name="YC${i}">
                                    <g:if test="${i != makeReportOneStep.size() - 1}">
                                        <a href="${request.getContextPath()}/MakeReport/makeReport?naqi=<%=dataInstance.NAQI%>&yanchi=延迟&startTime=${startTime}&endTime=${endTime}"
                                           data-toggle="navtab" data-id="dialog-normal"
                                           data-options="{id:'oneReportStep', title:'制造报表'}">${dataInstance["${headInstance}"]}</a>
                                    </g:if>
                                    <g:else>
                                        ${dataInstance["${headInstance}"]}
                                    </g:else>
                                </td>
                            </g:if>
                        %{-- 未完成外 --}%
                            <g:if test="${headInstance == 'WWCW'}">
                                <td name="WWCW${i}">
                                    <g:if test="${i != makeReportOneStep.size() - 1}">
                                        <a href="${request.getContextPath()}/MakeReport/makeReport?naqi=<%=dataInstance.NAQI%>&yanchi=未发货外&startTime=${startTime}&endTime=${endTime}"
                                           data-toggle="navtab" data-id="dialog-normal"
                                           data-options="{id:'oneReportStep', title:'制造报表'}">${dataInstance["${headInstance}"]}</a>
                                    </g:if>
                                    <g:else>
                                        ${dataInstance["${headInstance}"]}
                                    </g:else>
                                </td>
                            </g:if>
                        %{-- 未完成内 --}%
                            <g:if test="${headInstance == 'WWCN'}">
                                <td name="WWCN${i}">
                                    <g:if test="${i != makeReportOneStep.size() - 1}">
                                        <a href="${request.getContextPath()}/MakeReport/makeReport?naqi=<%=dataInstance.NAQI%>&yanchi=未发货内&startTime=${startTime}&endTime=${endTime}"
                                           data-toggle="navtab" data-id="dialog-normal"
                                           data-options="{id:'oneReportStep', title:'制造报表'}">${dataInstance["${headInstance}"]}</a>
                                    </g:if>
                                    <g:else>
                                        ${dataInstance["${headInstance}"]}
                                    </g:else>
                                </td>
                            </g:if>
                        %{--订单已完成--}%
                            <g:if test="${headInstance == 'DDYWC'}">
                                <td name="DDYWC${i}">
                                    <g:if test="${i != makeReportOneStep.size() - 1}">
                                        <a href="${request.getContextPath()}/MakeReport/makeReport?naqi=<%=dataInstance.NAQI%>&yanchi=订单已完成&startTime=${startTime}&endTime=${endTime}"
                                           data-toggle="navtab" data-id="dialog-normal"
                                           data-options="{id:'oneReportStep', title:'制造报表'}">${dataInstance["${headInstance}"]}</a>
                                    </g:if>
                                    <g:else>
                                        ${dataInstance["${headInstance}"]}
                                    </g:else>
                                </td>
                            </g:if>
                        %{-- 达成率 --}%
                            <g:if test="${headInstance == 'DCL'}">
                                <td name="DCL${i}">${dataInstance["${headInstance}"]}</td>
                            </g:if>
                        </g:each>
                    </tr>
                </g:each>
                </tbody>
            </table>
        </div>

        <div id="makeReportOneStepChart" style="margin: 20px auto; width: 100%; height: 450px;"></div>
    </g:if>
    <g:else>
        <g:render template="../template/emptyPanel"/>
    </g:else>
</div>
<script type="text/javascript" src="${request.getContextPath()}/js/echarts/v4/echarts.min.js"></script>
<script type="text/javascript">
    %{--$(function () {--}%
    %{--var sss = 'TQWC${makeReportOneStep.size()-1}'--}%
    %{--var sssShow = $("td[name='" + sss + "']").text() == '' ? 0 : parseFloat($("td[name='" + sss + "']").text())--}%
    %{--var aaa = 'AQWC${makeReportOneStep.size()-1}'--}%
    %{--var aaaShow = $("td[name='" + aaa + "']").text() == '' ? 0 : parseFloat($("td[name='" + aaa + "']").text())--}%
    %{--var bbb = 'YC${makeReportOneStep.size()-1}'--}%
    %{--var bbbShow = $("td[name='" + bbb + "']").text() == '' ? 0 : parseFloat($("td[name='" + bbb + "']").text())--}%
    %{--var array1 = new Array()--}%
    %{--var array2 = new Array()--}%
    %{--var array3 = new Array()--}%
    %{--var array4 = new Array()--}%
    %{--var array5 = new Array()--}%
    %{--var fm = aaaShow + bbbShow + sssShow--}%
    %{--var showFloat = 0--}%
    %{--for (var i = 0; i <${makeReportOneStep.size()-1}; i++) {--}%
    %{--var dcl = 'DCL' + i--}%
    %{--var dclShow = $("td[name='" + dcl + "']").text() == '' ? 0 : parseFloat($("td[name='" + dcl + "']").text())--}%
    %{--var tq = 'TQWC' + i--}%
    %{--var tqShow = $("td[name='" + tq + "']").text() == '' ? 0 : parseFloat($("td[name='" + tq + "']").text())--}%
    %{--var aq = 'AQWC' + i--}%
    %{--var aqShow = $("td[name='" + aq + "']").text() == '' ? 0 : parseFloat($("td[name='" + aq + "']").text())--}%
    %{--var yc = 'YC' + i--}%
    %{--var ycShow = $("td[name='" + yc + "']").text() == '' ? 0 : parseFloat($("td[name='" + yc + "']").text())--}%
    %{--var ddywc = 'DDYWC' + i--}%
    %{--var ddywcShow = $("td[name='" + ddywc + "']").text() == '' ? 0 : parseFloat($("td[name='" + ddywc + "']").text())--}%
    %{--array1[i] = tqShow--}%
    %{--array2[i] = aqShow--}%
    %{--array3[i] = ycShow--}%
    %{--array4[i] = dclShow--}%
    %{--array5[i] = ddywcShow--}%
    %{--}--}%
    %{--var array = new Array()--}%
    %{--for (var i = 0; i <${makeReportOneStep.size()-1}; i++) {--}%
    %{--array[i] = parseFloat(array1[i]) + parseFloat(array2[i]) + parseFloat(array3[i]) + parseFloat(array5[i])--}%
    %{--}--}%
    %{--for (var i = 0; i <${makeReportOneStep.size()-1}; i++) {--}%
    %{--showFloat += array4[i] * array[i] / fm--}%
    %{--}--}%
    %{--showFloat = showFloat.toFixed(2)--}%
    %{--var change = 'DCL' + ${makeReportOneStep.size()-1}--}%
    %{--if (isNaN(showFloat)) {--}%
    %{--$("td[name='" + change + "']").html(0)--}%
    %{--} else {--}%
    %{--$("td[name='" + change + "']").html(showFloat)--}%
    %{--}--}%
    %{--})--}%
    var makeReportOneStepChart = function () {
        var dateList = []
        var yieldList = []
        <g:each in="${makeReportOneStepChart}" status="i" var="dataInstance">
        dateList.push("${dataInstance.NAQI}");
        yieldList.push("${dataInstance.DCL}");
        </g:each>
        var myChart = echarts.init(document.getElementById("makeReportOneStepChart"));
        option = {
            title: {
                text: '纳期达成率'
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    label: {
                        backgroundColor: '#6a7985'
                    }
                }
            },
            legend: {
                data: ['达成率']
            },
            toolbox: {
                feature: {
                    saveAsImage: {}
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: [
                {
                    name: '纳期',
                    show: true,
                    type: 'category',
                    boundaryGap: false,
                    data: dateList,
                    axisLabel: {
                        rotate: 25,
                        show: true
                    }
                }
            ],
            yAxis: [
                {
                    name: '达成率',
                    type: 'value'
                }
            ],
            series: [
                {
                    name: '达成率',
                    type: 'line',
                    stack: 'yield',
                    itemStyle: {
                        normal: {
                            label: {
                                show: true,
                                color: '#6a7985'
                            }
                        }
                    },
                    data: yieldList
                }
            ]
        };
        myChart.setOption(option, true);
    }

    $(function () {
        <g:if test="${makeReportOneStep.size() > 0}">
        makeReportOneStepChart();
        </g:if>
    });
</script>